import io from "@hyoga/uni-socket.io";
import { encryptWeb, decryptWeb } from "./crypto.js";
// 获取用户信息
const userId = 114841;

// 创建 Socket 实例
const socket = io("http://59.110.8.225:19981", {
  transports: ["websocket"],
  auth: {
    userId: userId,
    token: encryptWeb(JSON.stringify({ time: Date.now(), userId: userId })),
  },
});

// 导出 Socket 实例
export {
  socket
};

// 发送自定义事件
function sendsocket() {
  socket?.emit("customEvent", {
    event: "abc",
    data: {
      userId: "111",
    },
  });
}

